package com.cq.hd.system.controller;

import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.support.ExcelTypeEnum;
import com.cq.hd.common.response.Result;
import com.cq.hd.common.response.ResultGenerator;
import com.cq.hd.system.api.TbHfMccApi;
import com.cq.hd.system.api.vo.HfMccVo;
import com.cq.hd.system.api.vo.HfRegionVo;
import com.cq.hd.system.excel.HfMccListener;
import com.cq.hd.system.excel.dto.HfMccExcelDto;
import com.cq.hd.system.service.TbHfMccService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;
import java.nio.charset.Charset;
import java.util.List;
import java.util.Set;

/**
 * <p>
 * 汇付mcc表 前端控制器
 * </p>
 *
 * @author mYunYu
 * @since 2023-12-25
 */
@RestController
public class TbHfMccController implements TbHfMccApi {

    @Autowired
    private TbHfMccService hfMccService;

    @ApiOperation(value = "根据id获取汇付的mcc列表数据")
    @ApiImplicitParam(name = "id", value = "id:0：获取省份，其他id：获取市区数据", defaultValue = "0", paramType = "query", dataType = "Integer")
    @ApiResponse(response = HfMccVo.class, code = 200, message = "接口返回对象参数")
    @Override
    public Result<List<HfMccVo>> listHfMccById(Integer id) {
        return ResultGenerator.success(hfMccService.listHfMccById(id));
    }

    @ApiOperation(value = "获取商家/商户行业类型")
    @ApiResponse(response = HfMccVo.class, code = 200, message = "接口返回对象参数")
    @Override
    public Result<List<HfMccVo>> listHfMccByGrade(int grade) {
        return ResultGenerator.success(hfMccService.listHfMccByGrade(grade));
    }

    @ApiOperation(value = "根据mccCode获取商家/商户行业类型")
    @ApiResponse(response = HfMccVo.class, code = 200, message = "接口返回对象参数")
    @Override
    public Result<List<HfMccVo>> listHfMccByMccCodes(Set<String> mccList) {
        return ResultGenerator.success(hfMccService.listHfMccByMccCodes(mccList));
    }

    //    @ApiOperation(value = "导入")
//    @PostMapping("/import")
//    public Object importClue(MultipartFile file) throws IOException {
//        EasyExcel.read(file.getInputStream(), HfMccExcelDto.class, new HfMccListener(hfMccService))
//                .excelType(ExcelTypeEnum.XLSX).charset(Charset.forName("GBK")).sheet().doRead();
//        return ResultGenerator.success();
//    }


}
